const express = require('express');
const router = express.Router();
const db = require('../db'); // 假设db.js位于上一级目录

// 获取动物列表
router.get('/', async (req, res) => {
  try {
    const [rows] = await db.query('SELECT * FROM animals');
    res.status(200).json(rows);
  } catch (error) {
    console.error(error);
    res.status(500).send('Error retrieving data from database.');
  }
});

module.exports = router;